OpenRoads Designer CONNECT Edition SDK Help

Read and apply design standard values

The below code shows how to read the values from the design standard and apply it to elements. Here sample element of type CircularArc is created by reading default radius value from active design standard.


//Required References
using System;
using System.Collections.Generic;
using System.Linq;
using Bentley.GeometryNET;
using Bentley.CifNET.DesignStandardsModel;
using Bentley.DgnPlatformNET;
using Bentley.MstnPlatformNET;
using Bentley.CifNET.GeometryModel.SDK;
using Bentley.CifNET.GeometryModel.SDK.Edit;

 public bool ApplyDesignStandard()
        {
            //Get Design standard model manager 
            Bentley.CifNET.DesignStandardsModel.DesignStandardModelManager designStandardModelManager = DesignStandardModelManager.Instance;

            //Get active design standard 
            Bentley.CifNET.DesignStandardsModel.DesignStandard activeDesignStandard = designStandardModelManager.CurrentDesignStandard;

            //Get the first design standard from library if current design standard is not available
            if (activeDesignStandard == null)
            {
                IDictionary<string, DesignStandardsModel> designStandarsFromLibraries = designStandardModelManager.DesignStandardsModelsLibrary;
                DesignStandardsModel designStandardModel = designStandarsFromLibraries.ElementAt(0).Value;
                DesignStandardNameSet designStandardNameSet = designStandardModel.DesignStandardNameSet;
                foreach (DesignStandard designStandard in designStandardNameSet)
                {
                    activeDesignStandard = designStandard;
                    break;
                }
                if (activeDesignStandard == null) return false;
            }

            //Get defualt radius value from design standard for applying to arc
            double radius = activeDesignStandard.DefaultRadius;
            if (radius <= 0.0) radius = 300; //Set default radius value if it is 0

            DPoint3d center = new DPoint3d(10000, 10000, 0);
            double startDir = 0;
            double sweepAngle = Math.PI / 2;

            //Create new CircularArc 
            Bentley.CifNET.LinearGeometry.CircularArc circularArc = new Bentley.CifNET.LinearGeometry.CircularArc(center, radius, startDir, sweepAngle);
            if (circularArc == null) return false;

            //Create alignment from circularArc for displaying it to UI 
            Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit.GetActive();
            if (con == null) return false;
            GeometricModel geomModel = con.GetOrCreateGeometricModel();
            if (geomModel == null) return false;

            Alignment al = geomModel.CreateAlignmentByLinearElement(circularArc, true);
            if (al == null) return false;

            return true;
        }